package restaurant;

import restaurant.iterators.Iterator;

/**
 * The Class cmdMenuByPrice.
 * 
 * @author Ebonie
 */

public class cmdMenuByPrice implements Command
{

	/** The info. */
	private InformationAggregator info;

	/** The price. */
	private double price;



	/**
	 * Instantiates a new cmd menu by price.
	 * 
	 * @param info the info
	 * @param price the price
	 */
	public cmdMenuByPrice(InformationAggregator info, int price) {
		this.info = info;
		this.price = price;
	}



	/**
	 * Execute.
	 * 
	 * @return the menu by price.
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{
		Menu menu = info.getMenu();
		Iterator priceIterator = menu.getByPriceIterator(price);
		MenuItem item;
		Menu priceMenu = new Menu();

		while (priceIterator.hasNext()) {
			item = (MenuItem) priceIterator.next();

			if (item.isAvailable())
				priceMenu.add(item);
		}

		return priceMenu;
	}

}
